import { createApp } from 'vue'
import './assets/default/styles/common.less'
import(`@/assets/${process.env.VITE_THEME_NAME}/styles/sjplatformstyle.less`);
import { createPinia } from 'pinia';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import App from './App.vue'
import router from './router'; // 路由配置文件
import { useLoginUserStore } from './store'

//element-plus
import ElementPlus from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/theme-chalk/index.css';
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app = createApp(App);
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate)
app.use(pinia as any);

// // 在应用初始化时处理动态路由，解决浏览器刷新的时候二级路由跳转放到一级路由上的问题
const loginUserStore = useLoginUserStore();
loginUserStore.dynamicRoutes();

app.use(router as any);//全局路由
app.use(ElementPlus as any, {
  locale: zhCn,
});//element ui
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.mount('#app');